<?php

#################################################################
#								HTML
#################################################################

/**
 * Subtitle element register as 'element/subtitle' 
 * 
 * $vars['subtitle']			Page title (String)
 * $vars['pulsate']			Blink text effect (int)
 * $vars['class']			Element class (String)
 * $vars['id']				Element id (String) 
 * 
 * @author Pablo
 * @since 1.0 
 */

if($_CONTEXT=='HTML'){
	
	$_CSS_STACK->push(blg_get_site_url().'element/subtitle.css');
	$_JS_STACK->push(blg_get_site_url().'element/subtitle.js');		
	
	//PREPARE DEFAULTS	
	if(!is_int($vars['pulsate']))
		$vars['pulsate']= 0;		
		
	$class= 'subtitle_element';
	if(!empty($vars['class']))
		$vars['class']= $class.' '.$vars['class'];
	else
		$vars['class']= $class;

	if(empty($vars['id']))
		$vars['id']= 'subtitle_'.random_string(12);		

echo <<<HTML
<span id="$vars[id]" class="$vars[class]">$vars[subtitle]</span>
HTML;

	if($vars['pulsate']>0){
		$code="$('#".$vars['id']."').effect('pulsate', { times:".$vars['pulsate']." }, 900);";		
		$_JS_CODE->append($code, ON_DOC_READY);				
	}	
	else{
		$code="
		blg_element_subtitle_effect('".$vars['id']."');
		blg_element_subtitle_animate('".$vars['id']."');				
		";
		
		$_JS_CODE->append($code, ON_DOC_READY);				
	}

}
#################################################################
#								JS
#################################################################
elseif($_CONTEXT=='JS'){ ?>

function blg_element_subtitle_color1(id){
	$('#'+id).animate({color: '#88888'}, 1000 );
}

function blg_element_subtitle_color2(id){
	$('#'+id).animate({color: '#55555'}, 1000 );
}

function blg_element_subtitle_effect(id){
	blg_element_subtitle_color1(id);
	setTimeout('blg_element_subtitle_color2(\''+id+'\')', 1000);
}

function blg_element_subtitle_animate(id){
	setInterval('blg_element_subtitle_effect(\''+id+'\')', 5000);
}

<?php }
#################################################################
#								CSS
#################################################################
elseif($_CONTEXT=='CSS'){ ?>

span.subtitle_element{
	display: inline;
	font-size: 18px;
	line-height: 20px;
	color: #888888;	
	font-weight: bold;
	font-family: arial,verdana,tahoma,sans-serif;
	padding: 2px 0 5px 0;	
}

<?php }
